GBML manual / Collision

mask_x

How far right of this instance’s own `x` the collision box sits, in pixels (negative is left). 0 (the default) centers it on the instance, which is what every mask did before this existed.

Syntax

mask_x: int

Description

How far right of this instance's own x its collision box sits, in pixels. Negative moves it left. 0, the default, centers the box on the instance, which is where every mask sat before this existed.

Example

mask_w = 12;
mask_x = 6;

A narrow box shifted to the right - a character who reaches with one arm, or a door that only blocks on its hinged side.

It moves the box, not the instance

x keeps meaning x. Nothing about this offset moves the instance, changes where its sprite is drawn, or shows up in anything that reads a position.

What it does change is where the rectangle is, and everything that asks about the rectangle sees the moved one: collides, pos_free, pos_meeting, collision_rect, and move_slide/move_bounce as they walk along a wall.

To read the moved rectangle back in room coordinates, use box_left and its three siblings. Those are in room space; mask_x is an offset from the instance, so the two are not interchangeable.

Why an offset at all

Without one, a mask can only ever be centered - and a centered box is the wrong shape for a great many things. A box smaller than the art lands at the art's middle, which for a standing character is roughly their waist. Half the point of a smaller mask is putting it somewhere specific.

Once the box can move, "collide on the feet", "the hitbox is out in front of the sword", and "this sign only blocks the post it stands on" are all one number each.

On the GBA

Moves the BOX, never the instance: `x` keeps meaning `x`, and `box_left`/`box_right` read back the moved rectangle. `move_slide`/`move_bounce` walk the box rather than the origin, so an offset mask is what actually meets the wall.

See also: mask_ymask_wmask_hbox_leftmove_slide